/*
 * SKZR.ORG JS Library 0.1
 * Copyright(c) 2009-2011, SKZR.ORG JS, LLC.
 * skzr.org@gmail.com
 */
 
Ext.ns("Skzr.login");

/**
 * @type String 缺省路径设置
 */
Skzr.login.path='.';

/**
 * widht:526
 * height:290
 * @param {} config
 */
Skzr.login.LoginPanel = function(config) {
	var loginForm = new Ext.form.FormPanel({
		defaultType:'textfield',
		style:'background:#ffffff;padding:25px 35px 30px 16px;',
		labelAlign:'right',
		labelWidth:60,
		region:'center',
		defaults:{border:false,msgTarget:'side'},
		waitMsgTarget : true,
		items:[
	       {
		       fieldLabel:'登录帐号',
		       allowBlank:false,
		       regex:/^[a-zA-Z]{2,20}$/,
			   regexText:'只能为2到20位字母',
		       name:'userName',
		       width:135
		   },{
		       fieldLabel:'登录密码',
		       allowBlank:false,
		       inputType:'password',
		       regex:/^.{4,}$/,
		       regexText:'长度不能少于4位',
		       name:'password',
		       width:135
		   },{
		       xtype:'panel',
		       defaults:{border:false},
		       layout:'column',
		       items:[
	              {
		              columnWidth:.5,
		              layout:'form',
		              items:[
	                     {
		                     anchor:'98%',
		                     xtype:'textfield',
		                     fieldLabel:'效验码',
		                     allowBlank:false,
		                     maxLength:6,
		                     name:'checkCode'
		                 }
				      ]
		          },{   
			          xtype : 'checkCode',
			          columnWidth:.4,
			          src : 'authImg.action',
			          handler : true
		          }
				]
		   }
		],
		buttons:[
			{text:'登陆', handler:function() {
				loginForm.getForm().submit({
					url:'login.action',
					success:function(form, action) {
						debugger;
					},
					failure:function(form, action) {
						debugger;
					}
				});
			}},
			{text:'取消', handler:function() {
				loginForm.getForm().reset();
			}}
		]
	});
	this.loginForm = loginForm;
	config = Ext.applyIf({
		layout:'border',
		width:526,
		height:290,
		defaults:{border:false},//防止出现边框
		items:[
			{
				region:'north',
				height:56,
				html:'<img src="' + this.getPath() + '/head.gif"/>'				
			},
			{
				region:'south',
				height:56,
				html:'<img src="' + this.getPath() + '/foot.gif"/>'				
			},
			{
				region:'west',
				width:253,
				html:'<img src="' + this.getPath() + '/left.gif"/>'				
			}, this.loginForm
		]
	}, config || {});
	Ext.apply(this, config);
	Skzr.login.LoginPanel.superclass.constructor.call(this);
};

Ext.extend(Skzr.login.LoginPanel, Ext.Panel, {
	getPath:function() {
		return Skzr.login.path;
	}
});

Ext.reg("loginPanelSkzr", Skzr.login.LoginPanel);